// index page
// ============

define(['require', 'zepto', 'utils', 'sui'], function(require, $, utils) {
  return {
    init: function() {
      this.initPage()
    },
    
    initPage: function() {
      var that = this;
      $(document).on("click", ".wheely-coupons-claim", function() {
        var mobile = $('input[name="mobile"]').val();
        var flag = true;
        if(!/^((13)|(15)|(17)|(18))\d{9}$/.test(mobile) || !mobile){
            $.toast('请输入正确的手机号');
            flag = false;
        }
        
        if(flag) {
        	$.post(window.__CTX__.root + "/wheely-coupons", {
                'mobile': mobile
              }).done(function(response) {
           	   response = JSON.parse(response)
               if(response.code == 0) {
            	   $.toast(response.message);
            	   setTimeout(function() {
            		   if(response.data.url) {
            			   location.href = window.__CTX__.root + response.data.url;
            		   }
            	   }, 2000)
            	   
               } else {
            	   $.toast(response.message);
               }
           })
        }
        
      });
      
    }
  }
})